Converting mysql query result into very specific json structure

welcome to shbcf.ru